package asimes.time;

import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;

public class DateTimeTest {
    public static void main(String[] args) {
        LocalDateTime localDateTime = LocalDateTime.now();
        System.out.println(localDateTime);
        ZonedDateTime zonedDateTime = localDateTime.atZone(ZoneId.of("UTC"));
        System.out.println(zonedDateTime);
        ZonedDateTime zonedDateTime1 = zonedDateTime.withZoneSameInstant(ZoneId.of("Asia/Shanghai"));
        System.out.println(zonedDateTime1);
        String format = localDateTime.format(DateTimeFormatter.ISO_DATE_TIME);
        System.out.println(format);


        LocalDateTime parsed = LocalDateTime.parse(format);
        System.out.println(parsed);
    }
}
